<template>
  <view :style="themeColor">
    <view class="page">
      <fu-custom bgColor="bg-white" :isBack="true" :isBottom="true">
        <block slot="content">发票管理</block>
      </fu-custom>

      <view class="flex flex-direction align-stretch benben-flex-layout managementInvoices_flex_1">
        <template v-for='(item,key0) in dataList'>
          <view class='flex flex-direction align-stretch managementInvoices_fd1_0' @tap.stop="handleClickFunc(item.aid)"
            :key='key0'>
            <view class='flex flex-direction align-stretch'>
              <view class='flex flex-wrap align-center managementInvoices_fd1_0_c0_c0'>
                <text class='managementInvoices_fd1_0_c0_c0_c0'>{{item.username}}</text>
                <view class='flex flex-wrap align-center managementInvoices_fd1_0_c0_c0_c1'>
                  <text class='managementInvoices_fd1_0_c0_c0_c1_c0' v-if=" item.type=='1'">个人</text><text
                    class='managementInvoices_fd1_0_c0_c0_c1_c0' v-if=" item.type=='2'">公司</text>
                </view>
              </view>
              <view class='flex flex-wrap align-center managementInvoices_fd1_0_c0_c1'>
                <text class='managementInvoices_fd1_0_c0_c1_c0'>联系邮箱</text>
                <text class='flex-sub managementInvoices_fd1_0_c0_c1_c1'>{{item.email}}</text>
              </view>
              <view class='flex flex-wrap align-center managementInvoices_fd1_0_c0_c1'>
                <text class='managementInvoices_fd1_0_c0_c1_c0'>联系电话</text>
                <text class='flex-sub managementInvoices_fd1_0_c0_c1_c1'>{{item.mobile}}</text>
              </view>
              <view class='flex flex-wrap align-center' v-if=" item.type=='2'">
                <text class='managementInvoices_fd1_0_c0_c1_c0'>公司税号</text>
                <text class='flex-sub managementInvoices_fd1_0_c0_c1_c1'>{{item.tax_number}}</text>
              </view>
              <view class='flex align-center justify-between managementInvoices_fd1_0_c0_c4'>
                <view class='flex flex-wrap align-center' @tap.stop="SelectDefaultFunc(item.aid,item.is_default)">
                  <image class='managementInvoices_fd1_0_c0_c4_c0_c0' mode="aspectFit" :src='STATIC_URL+"3.png"'
                    v-if="item.is_default=='1'"></image>
                  <image class='managementInvoices_fd1_0_c0_c4_c0_c0' mode="aspectFit" :src='STATIC_URL+"135.png"'
                    v-if="item.is_default=='0'"></image>
                  <text class='managementInvoices_fd1_0_c0_c4_c0_c1'>默认发票</text>
                </view>
                <view class='flex flex-wrap align-center'>
                  <view class='flex flex-wrap align-center' @tap.stop="getAddressIdFunc(item.aid)">
                    <image class='managementInvoices_fd1_0_c0_c4_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"6.png"'>
                    </image>
                    <text class='managementInvoices_fd1_0_c0_c4_c1_c0_c1'>删除</text>
                  </view>
                  <view class='flex flex-wrap align-center managementInvoices_fd1_0_c0_c4_c1_c1'>
                    <image class='managementInvoices_fd1_0_c0_c4_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"7.png"'>
                    </image>
                    <text class='managementInvoices_fd1_0_c0_c4_c1_c0_c1'>编辑</text>
                  </view>
                </view>
              </view>
            </view>
          </view>
        </template>

        <view class='flex flex-wrap align-center justify-center managementInvoices_fd1_1'>
          <button class='managementInvoices_fd1_1_c0'>添加新的抬头</button>
        </view>
      </view>


      <benben-popup v-model="popupShow1661425659576" :mask="true" :mask-close-able="true" mode='center'>
        <!---删除地址弹窗flex布局开始-->
        <view class="flex flex-direction flex-wrap align-center managementInvoices_flex_2">
          <text class='managementInvoices_fd2_0'>提示</text>
          <text class='managementInvoices_fd2_1'>确定删除该发票？</text>
          <view class='flex align-center managementInvoices_fd2_2'>
            <button class='managementInvoices_fd2_2_c0' @tap.stop="popupShow1661425659576=false">取消</button>
            <button class='managementInvoices_fd2_2_c1' @tap.stop="deleteAddressFunc()">确定</button>
          </view>
        </view>

        <!---删除地址弹窗flex布局结束-->

      </benben-popup>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "popupShow1661425659576": false,
        "dataList": [],
        "address_ids": "",
        "switch_id": "",
        "invoiceList": "",
        "is_change": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        is_change
      } = options
      if (is_change !== undefined) this.is_change = is_change
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getListFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //抛出选择的地址
      handleClickFunc(aid) {
        if (this.is_change == '1') {
          this.switch_id = aid;
          uni.$emit('isokaddid', this.switch_id)
          setTimeout(() => {
            this.$urouter.navigateBack(1);
          }, 500)
        }
      },
      //地址管理-地址列表
      async getListFunc() {
        //请求方法
        //数据验证

        let datadataList = await this.$api.post(global.apiUrls.post641848d371e2f, {

        });

        if (datadataList.data.code != 1) {
          this.$message.info(datadataList.data.msg);
          return
        }
        let infodataList = datadataList.data;
        this.dataList = infodataList.data

      },
      //获取地址id
      getAddressIdFunc(id) {
        this.address_ids = id;
        this.popupShow1661425659576 = true;
      },
      //删除地址
      async deleteAddressFunc() {
        //请求方法
        //数据验证

        let data641ec9d300c00 = await this.$api.post(global.apiUrls.post641ec9d300c00, {
          aid: this.address_ids
        });

        if (data641ec9d300c00.data.code != 1) {
          this.$message.info(data641ec9d300c00.data.msg);
          return
        }



        this.popupShow1661425659576 = false;
        this.getListFunc()
        this.$message.info('删除成功');
      },
      //选择默认
      async SelectDefaultFunc(defaulitID, defaulitid) {
        if (defaulitid == 0) {
          //请求方法
          //数据验证

          let data647efc94037dd = await this.$api.post(global.apiUrls.post647efc94037dd, {
            address_id: defaulitID
          });

          if (data647efc94037dd.data.code != 1) {
            this.$message.info(data647efc94037dd.data.msg);
            return
          }



          this.$message.info('设置成功');
          this.getListFunc()
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .managementInvoices_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .managementInvoices_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
  }

  .managementInvoices_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333;
  }

  .managementInvoices_fd0_0_c0 {
    width: 180rpx;
  }

  .managementInvoices_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .managementInvoices_flex_1 {
    border-top: 1px solid #F6F7F9;
    margin: 0rpx 0rpx 20rpx 0rpx;
    padding: 0rpx 0rpx 150rpx 0rpx;
  }

  .managementInvoices_fd1_1_c0 {
    background: var(--benbenbgColor7);
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    font-size: 32rpx;
    color: rgba(255, 255, 255, 1);
    width: 686rpx;
    height: 88rpx;
    line-height: 88rpx;
    font-weight: 400;
  }

  .managementInvoices_fd1_1 {
    width: 750rpx;
    position: fixed;
    left: 0rpx;
    bottom: calc(40rpx + var(--window-bottom));
  }

  .managementInvoices_fd1_0_c0_c4_c1_c1 {
    margin: 0rpx 0rpx 0rpx 67rpx;
  }

  .managementInvoices_fd1_0_c0_c4_c1_c0_c1 {
    line-height: 28rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #666666;
  }

  .managementInvoices_fd1_0_c0_c4_c1_c0_c0 {
    width: 30rpx;
    height: 30rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 12rpx 0rpx 0rpx;
  }

  .managementInvoices_fd1_0_c0_c4_c0_c1 {
    line-height: 32rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(102, 102, 102, 1);
  }

  .managementInvoices_fd1_0_c0_c4_c0_c0 {
    width: 36rpx;
    height: 36rpx;
    margin: 0rpx 14rpx 0rpx 0rpx;
  }

  .managementInvoices_fd1_0_c0_c4 {
    border-top: 1px solid #eee;
    padding: 26rpx 0rpx 0rpx 0rpx;
    margin: 28rpx 0rpx 0rpx 0rpx;
  }

  .managementInvoices_fd1_0_c0_c1_c1 {
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 40rpx;
  }

  .managementInvoices_fd1_0_c0_c1_c0 {
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 40rpx;
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .managementInvoices_fd1_0_c0_c1 {
    margin: 0rpx 0rpx 16rpx 0rpx;
  }

  .managementInvoices_fd1_0_c0_c0_c1_c0 {
    color: var(--benbenFontColor0);
    font-size: 22rpx;
    font-weight: 400;
    line-height: 30rpx;
  }

  .managementInvoices_fd1_0_c0_c0_c1 {
    background: #DCEBFF;
    border-radius: 4rpx 4rpx 4rpx 4rpx;
    padding: 4rpx 10rpx 2rpx 10rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .managementInvoices_fd1_0_c0_c0_c0 {
    line-height: 40rpx;
    font-size: 28rpx;
    font-weight: 600;
    color: #1A1A1A;
    max-width: 290rpx;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .managementInvoices_fd1_0_c0_c0 {
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .managementInvoices_fd1_0 {
    border: 1px solid #eee;
    background: var(--benbenbgColor1);
    padding: 30rpx 32rpx 20rpx 32rpx;
    background-size: 100% auto !important;
    margin: 0rpx 0rpx 20rpx 0rpx;
  }

  .managementInvoices_flex_2 {
    background: #fff;
    margin: 0rpx 105rpx 0rpx 105rpx;
    background-size: #eee;
    border-radius: 25rpx 25rpx 25rpx 25rpx;
    padding: 40rpx 0rpx 0rpx 0rpx;
  }

  .managementInvoices_fd2_2_c1 {
    background: var(--benbenbgColor1);
    line-height: 110rpx;
    border-radius: 0rpx 0rpx 16rpx 0rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor5);
    width: 270rpx;
    height: 110rpx;
  }

  .managementInvoices_fd2_2_c0 {
    border-right: 1px solid #EEEEEE;
    background: transparent;
    border-radius: 0rpx 0rpx 0rpx 16rpx;
    font-size: 32rpx;
    color: rgba(153, 153, 153, 1);
    height: 110rpx;
    line-height: 110rpx;
    width: 270rpx;
  }

  .managementInvoices_fd2_2 {
    border-top: 1px solid #eee;
  }

  .managementInvoices_fd2_1 {
    font-size: 32rpx;
    font-weight: 400;
    line-height: 52rpx;
    color: #333333;
    margin: 40rpx 0rpx 39rpx 0rpx;
  }

  .managementInvoices_fd2_0 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 500;
    line-height: 45rpx;
  }
</style>